<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body style="padding: 200px;">
		<input type="button" name="" id="" value="打开窗口" onclick="openWindow();"/>
		<input type="button" name="" id="" value="关闭窗口" onclick="closeWindow();"/>
	</body>
	
	<script type="text/javascript">
		var w;
		function openWindow() {
			w = window.open('https://www.baidu.com');
			console.log(w);
		}
		
		function closeWindow() {
			w.close();
		}
	</script>
</html>